home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19990725-20000114 / 000427_news@columbia.edu _Fri Jan 7 19:23:42 2000.msg < prev    next >
Internet Message Format  |  2020-01-01  |  7KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id TAA25383
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Fri, 7 Jan 2000 19:23:42 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id SAA11271
  7.     for kermit.misc@watsun.cc.columbia.edu; Fri, 7 Jan 2000 18:53:59 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: C-Kermit 7.0 Case Study #01 - Cleaning Out Beta-Test Binaries
  11. Date: 7 Jan 2000 23:53:58 GMT
  12. Organization: Columbia University
  13. Message-ID: <855uam$b04$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@columbia.edu
  15.  
  16.  
  17. As time permits, we're going to try to show off some of C-Kermit 7.0's
  18. new features in a series of case studies posted here.  If you'd like
  19. to post your own stories, feel free -- that's what this newsgroup is
  20. for!  Ditto if you'd like to suggest a topic to be presented.
  21.  
  22. Today's case study shows how C-Kermit 7.0 can be used to clean up after
  23. itself.  As those of you who have been following our neverending saga
  24. know, the C-Kermit 7.0 release was preceded by a long series of Alpha
  25. and Beta tests, in each of which we tried to make binaries available for
  26. as many platforms as possible.  For example, the Solaris 2.5.1 Intel
  27. test binary names look like:
  28.  
  29.   cku193a03.solaris25-i386-2.5.1  <-- Edit 193 Alpha Test 03
  30.   cku195b07.solaris25-i386-2.5.1  <-- Edit 195 Beta  Test 07
  31.   cku196b11.solaris25-i386-2.5.1  <-- Edit 196 Beta  Test 11
  32.  
  33. And then the final release binary for this platform is called:
  34.  
  35.   cku196.solaris25-i386-2.5.1
  36.  
  37. Within a few days after release, we had about 170 final binaries (keep
  38. 'em coming!), and hundreds more test ones, each binary consuming about
  39. a megabyte of disk space.  Before long, our server disk was running out
  40. of space.
  41.  
  42. Problem: Given about 600 C-Kermit binaries, how to remove test binaries
  43. for builds that have a final release, but preserve test binaries for
  44. the other platforms that we don't yet have final builds for?
  45.  
  46. Here's how to do it with a Kermit script (the lines are tagged by letters
  47. that are not part of the script):
  48.  
  49.   a. #!/usr/local/bin/kermit +
  50.   b. cd /pub/ftp/kermit/bin/
  51.   c. space
  52.   d. .\%n := \ffiles(ck?196[-.]*,&a)
  53.   e. for \%i 1 \%n 1 {
  54.   f.     .\%f := \&a[\%i]
  55.   g.     echo \%f...
  56.   h.     .\%g := \freplace(\%f,196,19[3-6][ab][0-9][0-9]*)
  57.   i.     .\%m := \ffiles(\%g,&b)
  58.   j.     if ( > \%m 0 ) {
  59.   k.         echo { MATCHES: \%g: \%n}
  60.   l.         for \%j 1 \%m 1 {
  61.   m.             ; echo {   \flpad(\%j,2). \&b[\%j]}
  62.   n.             delete /verb \&b[\%j]
  63.   o.         }
  64.   p.     }
  65.   q. }
  66.   r. space
  67.   s. exit
  68.  
  69. Here's a line-by-line explanation:
  70.  
  71.  a. This line is used in UNIX to make the script directly executable
  72.     from the shell prompt, just like a shell script.  For details,
  73.     see the ckermit2.txt file, Section 7.19.
  74.  
  75.  b. We set our current directory to the Kermit binaries directory.
  76.  
  77.  c. The SPACE command tells how much disk space is used and free.
  78.  
  79.  d. This line shows a bunch of new stuff.  ".\%n := " is a new
  80.     way of assigning values to variables, explained in ckermit2.txt
  81.     Section 7.9.  It means the same as "assign \%n ".  There are
  82.     several other forms too, each for a different purpose.  The value
  83.     in this case is whatever is returned by the call to the built-in
  84.     function \ffiles(), namely the number of files that matches the
  85.     given pattern.  This function has been with us for years, but 
  86.     there are two new things to notice in the argument list.  First,
  87.     the pattern supports [xy] notation for characters in a set, and
  88.     second, the new second argument specifies an array to be loaded
  89.     with the names of all matching files, in this case all the
  90.     C-Kermit 7.0 final release binaries ("ck" followed by any single
  91.     character ('?') followed by "196" followed by either a hypen "-"
  92.     or a period ".", followed by other stuff "*").
  93.  
  94.  e. Now we loop through the \%n filenames in the \&a[] array.
  95.  
  96.  f. For ease of notation, we assign the current array element to \%f.
  97.  
  98.  g. Print the current filename.
  99.  
  100.  h. Now we construct a pattern to match all test versions of the same
  101.     build.  We do this by replacing the '6' of "196" in the original
  102.     filename by a pattern that matches '3', '4', '5', or '6' followed
  103.     by 'a' (for Alpha) or 'b' (Beta), followed by two digits.  For
  104.     complete details on Kermit's new pattern-matching syntax, see
  105.     Section 4.9 of ckermit2.txt.
  106.  
  107.  i. We set the variable \%m equal to the number of files that matches
  108.     this pattern, i.e. the number of test binaries we can delete for
  109.     this build.
  110.  
  111.  j. If \%m is greater than 0 we have some test binaries to delete.
  112.     Note the enclosing parentheses; these are optional (in this case)
  113.     but in more complicated situations they can be used for grouping
  114.     and precedence, e.g. in compound Boolean expressions used as IF
  115.     and WHILE conditions.  Also note the use of IF rather than XIF --
  116.     the distinction is no longer necessary.  See section 7.20 about
  117.     new IF syntax and Boolean expressions.
  118.  
  119.  k. We print the pattern and the number of matches.
  120.  
  121.  l. And we loop through the files whose names matched the pattern.
  122.  
  123.  m. This statemet was used instead of DELETE while debugging but then
  124.     was commented out for the real run (you can also use DELETE /SIMULATE
  125.     for this purpose).
  126.  
  127.  n. We delete the old test binary "verbosely", i.e. with a message.
  128.     Lines o-q are the closing brackets on the various loops and if's.
  129.  
  130.  r. We find out how much space we freed (a lot!).
  131.  
  132.  s. An EXIT command is included; otherwise Kermit issues its prompt
  133.     and waits for more commands.  Kerbang scripts are typically
  134.     terminated by EXIT.
  135.  
  136. Note that the arrays created by the \ffiles() function did not need to
  137. be declared; they were created dynamically.  The array-loading functions
  138. are explained in Section 4.11 and 7.10 of ckermit2.txt.
  139.  
  140. We run this script simply by typing its name.  No need to start Kermit
  141. first; in fact, we never even *see* Kermit.
  142.  
  143. This is a rather simple script.  In fact it could have done more; for
  144. example, removing ALL extraneous files, such as older test binaries for
  145. which newer test binaries exist, but not a final release binary.  Tasks
  146. like this are illustrated in some of the file management scripts in the
  147. C-Kermit script library:
  148.  
  149.   http://www.columbia.edu/kermit/ckscripts.html
  150.  
  151. - Frank